'use strict';
/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  /**
   * 后台管理
   */
  router.post('/api/upload/file', controller.uploadcos.file);
  router.post('/wx/upload/file', controller.uploadcos.file);

  /**
   * 用户权限相关
   */
  router.post('/api/user/login', controller.user.login);
  router.post('/api/user/updateUserRoles', controller.user.updateUserRoles);
  router.get('/api/user/getUserRoles', controller.user.getUserRoles);
  router.get('/api/user/getUserInfo', controller.user.getUserInfo);
  router.resources('user', '/api/user', controller.user);
  router.get('/api/role/list', controller.role.allList);
  router.resources('role', '/api/role', controller.role);
  router.get('/api/menu/list', controller.menu.allList);
  router.resources('menu', '/api/menu', controller.menu);

  /**
   * 业务代码
   */
  // Banner管理
  router.get('/api/banner/list', controller.banner.allList);
  router.resources('banner', '/api/banner', controller.banner);

  // 新闻管理
  router.get('/api/news/list', controller.news.allList);
  router.resources('news', '/api/news', controller.news);

  // 分类管理
  router.get('/api/category/list', controller.category.allList);
  router.resources('category', '/api/category', controller.category);

  // 商品管理
  router.get('/api/product/list', controller.product.allList);
  router.resources('product', '/api/product', controller.product);

  // 食品管理
  router.get('/api/food/list', controller.food.allList);
  router.resources('food', '/api/food', controller.food);
  // 聊天管理
  router.get('/api/chat/list', controller.post.allList);
  router.resources('chat', '/api/chat', controller.post);
};
